/**
 * @description 方向
 * @readonly
 * @enum {string}
 */
const Direction = {
  left: "left",
  right: "right",
  up: "up",
  down: "down",
};

/**
 * @typedef {ImageShapeOptions&{
 * direction?:Direction;
 * speed?:number;
 * }} MobileShapeOptions
 */

class MobileImageShape extends ImageShape {
  /**
   * @description 移动方向
   * @type {Direction}
   */
  direction;

  /**
   * @description 移动速度
   * @type {number}
   */
  speed;

  /**
   * @description 暂停
   * @type {boolean}
   */
  pause;

  /**
   * @description 构造函数
   * @param {MobileShapeOptions} options
   */
  constructor(options) {
    super(options);
    this.direction = options.direction ?? Direction.down;
    this.speed = options.speed ?? 0;
    this.pause = false;
  }

  move() {
    if (!this.pause) {
      if (this.direction === Direction.up) {
        this.y -= this.speed;
      }
      if (this.direction === Direction.down) {
        this.y += this.speed;
      }
      if (this.direction === Direction.left) {
        this.x -= this.speed;
      }
      if (this.direction === Direction.right) {
        this.x += this.speed;
      }
    }
  }
}
